package api

import (
	"github.com/gin-gonic/gin"
	jwt "github.com/golangblogs/gojwt"
	"short_video/api/handler"
	"short_video/api/middleware"
	"short_video/consts"
)

func ToadRouter(r *gin.Engine) {
	middleware.Cors()
	api := r.Group("api")
	{
		user := api.Group("user")
		{
			user.POST("/SendSms", handler.SendSms)
			user.POST("/login", handler.Login)
			user.Use(jwt.JWTAuth(consts.JWT_KEY))
			user.POST("/update/token", handler.GetUploadToken)
			user.POST("/list", handler.GetUserList)
			user.POST("/details", handler.DetailsUser)
			user.POST("/upload", handler.UploadUser) //管理员可冻结或解冻用户账户
		}
		chat := api.Group("chat")
		{
			chat.Use(jwt.JWTAuth(consts.JWT_KEY))
			chat.GET("/ws", handler.Chat)
		}
		file := api.Group("file")
		{
			file.POST("/upload/file", handler.UploadFile)
		}
		order := api.Group("order")
		{
			order.Use(jwt.JWTAuth(consts.JWT_KEY))
			order.POST("/recharge", handler.RechargeOrder)
			order.POST("/Vip", handler.VipOrder)
			order.POST("/order/details", handler.OrderDetailsOrder)
		}
		video := api.Group("video")
		{
			video.Use(jwt.JWTAuth(consts.JWT_KEY))
			video.POST("/add/video", handler.AddVideo)
		}
		damu := api.Group("damu")
		{
			damu.Use(jwt.JWTAuth(consts.JWT_KEY))
			damu.POST("add/damu", handler.AddDamu)
		}
		admin := api.Group("admin")
		{
			admin.POST("/admin", handler.Admin)
		}
	}

}
